library(tidyverse)
library(tigris)
library(censusapi)
library(sf)
library(mapview)
library(plotly)
options(
tigris_class = "sf",
tigris_use_cache = T # This stores tigris loads somewhere on your machine for much faster personal loading.
)
#list_jurisdictions_scc <- c("Gilroy","Los Gatos","Morgan Hill","Mountain View","Palo Alto","Santa Clara","Sunnyvale","Campbell","Los Altos","Milpitas","Cupertino","Los Altos Hills","Saratoga","Monte Sereno","San Jose")
county <- "Santa Clara"
jurisdiction <- "Los Gatos"
The following report contains interactive maps and graphs for Los Gatos, CA, a jurisdiction within Santa Clara County, that show the percentage of people staying completely at home during the past few months. We hope to use this information to outline the impact of the COVID-19 shelter-in-place order and other Non-Pharmaceutical Interventions (NPIs) on the tendency of people to stay completely at home. We utilized the social distancing dataset from Safegraph to obtain the results outlined in this report.
Loading Initial Geometries
We chose to break the jurisdiction of Los Gatos into individual block groups in order to obtain a level of geographic granularity that would be conducive to examine neighborhood-level behavior. The following map shows the block groups in and around Los Gatos, as well as the city boundary (bold red line).
county_blockgroups <-
block_groups("CA",county, cb=F, progress_bar=F)
jurisdiction_boundary <-
places("CA", cb=F, progress_bar=F) %>%
filter(NAME == jurisdiction)
jurisdiction_blockgroups <-
county_blockgroups %>%
dplyr::select(GEOID) %>%
st_join(jurisdiction_boundary %>% dplyr::select(geometry), left = F)
mapview(jurisdiction_blockgroups)+mapview(jurisdiction_boundary,alpha.region= 0, color = "red", lwd = 4)
Loading and Analyzing Social Distance Data
We first load in the social distance data provided by Safegraph, and narrow down the data to the Los Gatos level.
bay_socialdistancing <-
readRDS("/Users/juliawagenfehr/pCloud Drive/SFBI/Restricted Data Library/Safegraph/covid19analysis/bay_socialdistancing.rds")
jurisdiction_socialdistancing <-
bay_socialdistancing %>%
filter(origin_census_block_group %in% jurisdiction_blockgroups$GEOID)
The following graph illustrates the percent of people staying completely at home starting on January 1, 2020 and ending on April 4, 2020. The black line represents the mean % of people staying completely at home of all block groups within Los Gatos for each day. The light grey shaded area represents the standard deviation of the % of people staying completely at home across all block groups on each specific date.
jurisdiction_percenthome_bg <-
jurisdiction_socialdistancing %>%
mutate(
`% Completely at Home` = completely_home_device_count/device_count * 100,
date = date_range_start %>% substr(1,10) %>% as.Date()
) %>%
dplyr::select(origin_census_block_group,date,completely_home_device_count,device_count,`% Completely at Home`)
jurisdiction_percenthome_variance <-
jurisdiction_percenthome_bg %>%
group_by(date) %>%
summarize(
completely_home_device_count = sum(completely_home_device_count),
device_count = sum(device_count)
) %>%
dplyr::select(date) %>%
mutate(
mean_percenthome = 0,
sd_percenthome = 0
)
jurisdiction_percenthome_bg_altered <-
jurisdiction_percenthome_bg
for(i in 1:nrow(jurisdiction_percenthome_variance)){
for(j in 1:nrow(jurisdiction_percenthome_bg_altered)){
jurisdiction_percenthome_bg_altered <-
subset(jurisdiction_percenthome_bg_altered,date == jurisdiction_percenthome_variance$date[i])
}
jurisdiction_percenthome_variance$mean_percenthome[i] =
mean(jurisdiction_percenthome_bg_altered$`% Completely at Home`)
jurisdiction_percenthome_variance$sd_percenthome[i] =
sd(jurisdiction_percenthome_bg_altered$`% Completely at Home`)
jurisdiction_percenthome_bg_altered <-
jurisdiction_percenthome_bg
}
jurisdiction_percenthome_variance$mean_percenthome = round(jurisdiction_percenthome_variance$mean_percenthome, digits = 1)
jurisdiction_percenthome_variance$sd_percenthome = round(jurisdiction_percenthome_variance$sd_percenthome, digits = 1)
chart <-
jurisdiction_percenthome_variance %>%
ggplot(
aes(
x = date,
y = mean_percenthome
)
) +
geom_ribbon(aes(ymin = mean_percenthome - sd_percenthome, ymax = mean_percenthome + sd_percenthome), fill = "grey70") +
geom_line() +
labs(
x = "Date",
y = "Percent staying completely at home",
title = paste0(jurisdiction, ", CA")
)
chart %>% ggplotly()
In order to examine the trend of people staying completely at home after the Santa Clara County Shelter-in-Place Order was enacted, we drew a vertical dotted line one the date of the order (3/16/20). After comparing the points on both sides of this line, we can see that the percentage of people staying completely at home did indeed increase after the order was put in place.
chart <-
chart +
geom_vline(
aes(
xintercept = "2020-03-16" %>% as.Date() %>% as.numeric() # ggplotly needs vlines to be numeric
),
linetype="dotted"
) +
annotate("text",label= paste0(county , "County /nShelter-in-Place Order"), color = "black", x=(("2020-03-16" %>% as.Date())-6), y=55, size=2)
chart %>% ggplotly()
jurisdiction_percenthome_map <-
jurisdiction_percenthome_bg %>%
filter(date > max(date)-3) %>%
group_by(origin_census_block_group) %>%
summarize(`% Completely at Home` = round(mean(`% Completely at Home`),1)) %>%
left_join(jurisdiction_blockgroups, by = c("origin_census_block_group" = "GEOID")) %>%
st_as_sf()
mapview(jurisdiction_percenthome_map, zcol = "% Completely at Home", layer.name = paste0("% Completely<br>at Home,<br>",max(jurisdiction_percenthome_bg$date)-3," to<br>",max(jurisdiction_percenthome_bg$date)))
NPIs
Susan Athey from the Stanford Graduate School of Business has been working on a database of other Non-Pharmaceutical Interventions (NPIs) that have been enacted in the Bay Area. The following describe the non-pharmaceutical interventaions implemented in Los Gatos County and specifies the date they were put into effect.
npis <- read_csv("/Users/juliawagenfehr/Documents/GitHub/covid19-intervention-data/npis_raw_03-24-2020.csv")
npis_county <-
npis %>%
filter(locality == "santa_clara_county") %>%
mutate(
date = data_start %>% as.Date("%m/%d/%Y")
) %>%
dplyr::select(date,type_of_intervention,further_notes_comments) %>%
arrange(date)
kable(
npis_county,
caption = paste0(county, ' County Non-Pharmaceutical Interventions')
)
Santa Clara County Non-Pharmaceutical Interventions
| 2020-01-26 |
HE |
Virus prevention education published in response to early cases in CA |
| 2020-01-28 |
CI |
Adult male who had traveled to Wuhan, China and had been self-isolating at home |
| 2020-02-03 |
TR_China |
Nation-wide restriction of foreigners who have traveled to China in the past 14 days |
| 2020-03-01 |
HE |
County issues health recommendations for prevention |
| 2020-03-02 |
SOE |
CA Governor requests money from the Disaster Response Emergency Operations Account to fight COVID-19 |
| 2020-03-04 |
SOE |
CA Governor declares state of emergency |
| 2020-03-04 |
PL |
Paid leave policies put in place |
| 2020-03-05 |
SDO |
Recommendation that persons at higher risk of severe illness should stay home and away from crowded social gatherings |
| 2020-03-09 |
SDO |
Social distancing for vulnerable/at-risk populations |
| 2020-03-11 |
SOE |
NA |
| 2020-03-11 |
GS_1000 |
NA |
| 2020-03-13 |
GS_250 |
Applies to gambling venues, theme parks, theaters |
| 2020-03-13 |
PC |
Guidelines for physical closures of schools |
| 2020-03-14 |
GS_100 |
NA |
| 2020-03-16 |
PC |
NA |
| 2020-03-16 |
CPV |
Restrict dine-in options for restaurants/bars |
| 2020-03-17 |
NESC |
NA |
| 2020-03-17 |
SD |
NA |
| 2020-03-19 |
SD |
State-wide issue of “stay at home” order |
| 2020-03-19 |
NESC |
Non-essential services closed |
| 2020-03-20 |
CPV |
All city playgrounds closed |
The NPIs defined are:
- SDO - Social Distancing of particularly vulnerable portions of the population
- SD - Social Distancing of the general population
- GS_XX - Gathering size limitation, with the digits indicating the ceiling of acceptable gatherings. A government order indicating that gatherings above that size are prohibited
- CPV - Closure of Public Venues. A government order closing gathering venues for in-person service, such as restaurants, bars, and theaters
- PC - Closure of schools and universities
- NESC - Non-Essential Services Closure, i.e. a government order closing non-essential services and shops
- LD – Lock Down (pending)
- RGC – Religious Gathering Cancellation